$(function(){
	$(".work").on("click",function(){
		var id = $(this).prev().val();
			location.href ="homework/work/"+id;
	});
	
	$("#savebtn").on("click",function(){
		var checkeds =[]; 
		var checkedanswer =[]; 
		$('input[name="answercid"]').each(function(){ 
			checkeds.push($(this).val()); 
		}); 
		for(var i=0;i<checkeds.length;i++){
			$('input[name="answer_'+checkeds[i]+'"]:checked').each(function(){ 
				checkedanswer.push($(this).val()); 
			}); 
		}
		if(confirm('请确定该操作!\r\n【注意：】如果是提交答案，请不要重复提交！')){
		 	$("#workFrom").form('submit', {
	    		type:"POST",
                url: '/homework/saveanswer',
                data:1,success:function(success) {
                	if(success){
                		location.href ="/front_page";
                	}
                }
            });
		}
	});
	//提交答案
	$("#subbtn").on("click",function(){
		var checkeds =[]; 
		var checkedanswer =[]; 
		$('input[name="answercid"]').each(function(){ 
			checkeds.push($(this).val()); 
		}); 
		for(var i=0;i<checkeds.length;i++){
			$('input[name="answer_'+checkeds[i]+'"]:checked').each(function(){ 
				checkedanswer.push($(this).val()); 
			}); 
		}
		//保存暂不提交
		var id = $("#workid").val();
		if(confirm('请确定该操作!\r\n【注意：】如果是提交答案，请不要重复提交!')){
			$("#workFrom").form('submit', {
	    		type:"POST",
                url: '/homework/subanswer',
                data: 1,success:function(success) {
                	if(success){
                		location.href ="/front_page";
                	}
                }
            });
		}
	});
	
	$(".seework").on("click",function(){
		var id = $(this).prev().val();
		location.href ="homework/seework/"+id;
	});
});